/**
 * Created by zhaojm on 15/3/17.
 */
// 障碍物
game.BaseMoster = cc.Node.extend({
    _mosterSprite:null,
    _type : null,
    hadCollided:null,
    ctor:function(){
        this._super();

        this.hadCollided = false;   // 是否碰撞过

        this._type = this.getMosterType();
        //cc.log('moster  type===', this._type);




        this._mosterSprite = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame("moster" + this._type + ".png"));
        this._mosterSprite.setAnchorPoint(cc.p(0, 0));
        this.addChild(this._mosterSprite);
        this._mosterSprite.setPosition(cc.p(0,0));
        this.setContentSize(this._mosterSprite.getContentSize());

        //this.setScale(game.ConfigHelper.getMoaterScale());

        this.setAnchorPoint(cc.p(0, 0));


        if(this._type == 2){
            this._mosterSprite.runAction(new cc.RepeatForever(new cc.Animate(
                new cc.Animation([0, 1, 2, 2, 1, 0].map(function (i) {
                    return cc.spriteFrameCache.getSpriteFrame("moster2/" + i + ".png");
                }), 0.15)
            )));
        }


    },

    getMosterType : function(){
        return Math.floor(Math.random()*3);  // 0-2
    },



});